import 'package:flutter/material.dart';
import 'package:shenling/pages/task/components/emptyPage.dart';
import 'package:shenling/pages/task/components/goodsItem.dart';

class OnWay extends StatefulWidget {
  OnWay({super.key, required this.goodsList});
  List goodsList;
  @override
  State<OnWay> createState() => _OnWayState();
}

class _OnWayState extends State<OnWay> {
  List goodsList = [];
  @override
  void initState() {
    super.initState();
    setState(() {
      goodsList.clear();
      for (var item in widget.goodsList) {
        if (item['status'] == '2') {
          goodsList.add(item);
        }
      }
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: goodsList.isEmpty
          ? Center(
              child: EmptyPage(title: '无待提'),
            )
          : Padding(
              padding: const EdgeInsets.all(10),
              child: ListView.separated(
                itemBuilder: (BuildContext context, int index) {
                  return GoodsItem(
                    item: goodsList[index],
                  );
                },
                separatorBuilder: (BuildContext context, int index) {
                  return Container(
                    height: 1,
                    color: const Color.fromARGB(255, 241, 238, 238),
                  );
                },
                itemCount: goodsList.length,
              ),
            ),
    );

    // return GoodsItem();
  }
}
